package com.zhuchaooasystem.adapter.holder;

import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.jude.easyrecyclerview.adapter.BaseViewHolder;
import com.zhuchaooasystem.R;
import com.zhuchaooasystem.entity.ServiceProgressEntity;

import jp.wasabeef.glide.transformations.RoundedCornersTransformation;

/**
 * Created by zhangyajiang on 2017/1/17.
 */

public class ServiceScheduleHolder extends
        BaseViewHolder<ServiceProgressEntity.ResultBean.SuccessfulBean.DetailsBean> {

    TextView tv_title, tv_name, tv_content, tv_num, tv_state;
    ImageView imageView;

    public ServiceScheduleHolder(ViewGroup itemView) {
        super(itemView, R.layout.item_order_detail_recycleview);

        tv_title = $(R.id.order_title);
        tv_name = $(R.id.order_name);
        tv_content = $(R.id.order_content);
        tv_num = $(R.id.order_num);
        tv_state = $(R.id.order_state);

        imageView = $(R.id.order_image);

    }

    @Override
    public void setData(ServiceProgressEntity.ResultBean.SuccessfulBean.DetailsBean data) {
        super.setData(data);
        //商品内容
        if (data.getBanner() == null || data.getBanner().equals("")) {
            tv_content.setVisibility(View.INVISIBLE);
        } else {
            tv_content.setText(data.getBanner());
            tv_content.setVisibility(View.VISIBLE);
        }

        //已发货
        if (data.isWhetherDelivery()) {
            tv_state.setVisibility(View.VISIBLE);
        } else {
            tv_state.setVisibility(View.GONE);
        }

        tv_name.setText(data.getProductName());
        int num = (int) data.getQuantity();
        tv_num.setText("X" + num);
        tv_title.setText(data.getCategory());

        if (data.getPicPath()!=null){
            Glide.with(getContext()).
                    load(data.getPicPath()).placeholder(R.drawable.ic_image_default).error(R.drawable.ic_image_default)
                    .bitmapTransform(new RoundedCornersTransformation(getContext(), 30, 0, RoundedCornersTransformation.CornerType.ALL)).
                    into(imageView);

        }


    }
}
